<script>
import { mapState, mapMutations } from 'vuex'
export default {

	onLaunch: function () {
		console.log('App Launch')
		this.getstatic()
	},
	onShow: function () {
		console.log('App Show')
		//广告显示的时间  10分钟
		let adShowTime = 100 * 60 * 1000;
		// let adShowTime = 3000;

		//当前时间
		let nowTime = (new Date()).getTime();
		//开始隐藏的时间
		let leaveTime = this.$store.state.leaveTime;
		console.log(leaveTime);
		console.log("onshow:", nowTime, leaveTime)
		//开始比较
		if ((nowTime - leaveTime) >= adShowTime) {
			console.log('show ad');
			//跳转到开屏页
			uni.navigateTo({
				url: '/pages/ad/ad'
			})
		}
	},
	onHide: function () {
		console.log('App Hide')
		//记录app隐藏的开始时间
		// this.$store.commit('storeLeaveTime');
		this.storeLeaveTime()

	},
	methods: {
		...mapMutations(['setLoginStatic', 'storeLeaveTime']),
		getstatic() {
			const value = uni.getStorageSync('userLogin')
			// this.$store.commit('setLoginStatic', JSON.parse(value))
			if (value) this.setLoginStatic(JSON.parse(value))

		}
	}
}
</script>

<style  lang="scss">
/*每个页面公共css */
@import './common/css/common.scss';
@import './common/css/iconfont.css';
</style>
